// miniprogram/group_admin/pages/int_do_prob.js
const app = getApp().globalData;
const api = require("../../../utils/api.js")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    unitlist:[],
    hidden:true
  },
  //初始化智能刷题界面
  idData:(that)=>{
    var userData = wx.getStorageSync('USERDATA');
    var courseInfo = wx.getStorageSync('COURSEINFO');
    var parmas ={
      uid:userData.uid,
      sessionid:userData.sessionid,
      market: app.market,
      courseid:courseInfo.id,
      type:1,
      isPageing:0
    };
    var url="/study/getUnitlist";
    api.sendPostsSync(url,parmas)
    .then(
      value=>{
        that.setData({
          unitlist:value.unitlist
        });
      }
    )
    .catch(
      error=>{
        console.log("刷题界面初始化失败",error);
      }
    );
  },
  clickItem:async function(options){
    let that = this;
    let option = {
      unitid:options.currentTarget.dataset.res.unitid
    };
    let hidden = await api.clickItem(option);
    that.setData({
      hidden:hidden
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    //初始化智能刷题界面
    that.idData(that);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})